package com.app.controller;

import com.app.service.LogonService;
import com.app.util.Result;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;


@Controller
@RestController
@Data
public class LogonController {
    @Autowired
    private LogonService logonService;

    @GetMapping("/logon")
    public Result<String> logon(@RequestParam("mobile") String mobile,
                        @RequestParam("code") String code) {
        return logonService.logon(mobile, code);
    }

    @PostMapping("/face")
    public Result<String> updateUserAvatar(HttpSession session, MultipartFile file){
        return logonService.updateUserAvatar(session, file);
    }
}
